package com.nbufe.controller;

import com.nbufe.domain.ResponseResult;
import com.nbufe.domain.dto.process.AddEmissionOriginDto;
import com.nbufe.domain.dto.process.AddProcessDto;
import com.nbufe.domain.dto.process.EditEmissionDto;
import com.nbufe.domain.dto.process.QueryEmissionOriginDetailVo;
import com.nbufe.domain.vo.process.ProcessEmissionOriginVo;
import com.nbufe.service.ProcessService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @Author luzhiheng
 * @Date 2023/12/27 10:18
 */
@RestController
@RequestMapping("/process")
public class ProcessController {

    @Resource
    private ProcessService processService;

    @GetMapping("/queryAll")
    public ResponseResult queryAllProcess() {
        List<ProcessEmissionOriginVo> processEmissionOriginVoList = processService.queryAllProcess();
        return ResponseResult.okResult(processEmissionOriginVoList);
    }

    @DeleteMapping("/deleteProcess/{id}")
    public ResponseResult deleteProcess(@PathVariable Long id) {
        processService.deleteProcessById(id);
        return ResponseResult.okResult();
    }

    @PostMapping("/addProcess")
    public ResponseResult addProcess(@Valid @RequestBody AddProcessDto dto) {
        processService.addProcess(dto);
        return ResponseResult.okResult();
    }

    @PostMapping("/addEmissionOrigin")
    public ResponseResult addEmissionOrigin(@Valid @RequestBody AddEmissionOriginDto dto) {
        processService.addEmissionOrigin(dto);
        return ResponseResult.okResult();
    }

    @PostMapping("/editEmissionOrigin")
    public ResponseResult editEmissionOrigin(@Valid @RequestBody EditEmissionDto dto) {
        processService.editEmissionOrigin(dto);
        return ResponseResult.okResult();
    }

    @GetMapping("/queryEmissionOriginDetail/{id}")
    public ResponseResult queryEmissionOriginDetail(@PathVariable Long id) {
        QueryEmissionOriginDetailVo vo = processService.queryEmissionOriginDetail(id);
        return ResponseResult.okResult(vo);
    }

}
